package components.dialogs.collages
{
	import UIFree.ObjectEvent;
	import UIFree.uif_component;
	
	import components.clt_popupMenu;
	import components.clt_previewItem;
	
	import flash.events.Event;
	
	public class clt_collageItem extends clt_previewItem {
		public function clt_collageItem(index:int, parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight:int=0, a_data:*=null, styleClass:String='', previewURL:String='') {
			super(index, parent, ax, ay, awidth, aheight, a_data, styleClass, previewURL);
			if (_data && (_data.uid == clt.externalServer.viewer_id)) myCollage();
		}
		
		protected function myCollage(): void {
			new clt_popupMenu(clt.popupMenuLayer, this, [
				{
					caption: clt.locale.DELETECOLLAGE,
					method: function(): void {
						clt.alert(clt.locale.MESSAGE, clt.locale.DELETEREQUESTCOLLAGE, function(): void {
							clt.internalServer.removeGame(clt.externalServer.viewer_id, _data.id, function(a_data: Object): void {
								if (a_data.response[0] && a_data.response[0].deleteResult) dispose();
							});
						}, true);
					}
				}
			], doSelect);
		}
		
		private function doSelect(e: ObjectEvent): void {
			e.object.method();
		}
	}
}